﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommerceOne.Domains.Commons
{
    public class FilterGroup
    {
        private List<IFilterParam> filterParamList = new List<IFilterParam>();

        /// <summary>
        /// Adds the specified filter param.
        /// </summary>
        /// <param name="filterParam">The filter param.</param>
        /// <returns></returns>
        public FilterGroup Add(IFilterParam filterParam)
        {
            this.filterParamList.Add(filterParam);
            return this;
        }

        /// <summary>
        /// Adds the ranger.
        /// </summary>
        /// <param name="filterParams">The filter params.</param>
        /// <returns></returns>
        public FilterGroup AddRanger (IFilterParam[] filterParams)
        {
            this.filterParamList.AddRange(filterParams);
            return this;
        }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            string sqlStr = string.Join(" AND ", this.filterParamList);
            return " (" + sqlStr + ")";
        }
    }
}
